<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>My Cart</title>
    <link rel="stylesheet" type="text/css" href="<s:url value='/CSS/order/cart_list.css'/>">
  </head>
  <body>
    <div class="container">
      <div class="head">
        <s:include value="/WEB-INF/JSP/head.jsp"/>
      </div>
      <div class="body">
        <div class="left">
          <s:include value="/WEB-INF/JSP/order/left.jsp"/>
        </div>
        <div class="right">
          <s:set value="%{0}" var="totalPrice"></s:set>
          <div class="title">My Cart</div>
          <table>
            <tr class="tr1">
              <td class="td1">Product Name</td>
              <td class="td2">MarketPrice</td>
              <td class="td3">SalesPrice</td>
              <td class="td4">Quantity</td>
              <td class="td5">Delete</td>
            </tr>
            <s:iterator value="#session.cart" status="stat">
            <s:set value="%{#totalPrice + product.salesPrice * quantity}" var="totalPrice"/>
            <tr class="tr2" id="row_<s:property value='#stat.index'/>"
                onmouseover="onChange('row_<s:property value='#stat.index'/>', 0)" 
                onmouseout="onChange('row_<s:property value='#stat.index'/>', 1)">
              <td class="td1"><s:property value="product.name"/></td>
              <td class="td2"><s:property value="product.marketPrice"/></td>
              <td class="td3">
                <s:property value="product.salesPrice"/><br/>
                <s:if test="product.salesPrice < product.marketPrice">
                  (Saving:<b><s:property value="(product.marketPrice - product.salesPrice) * quantity"/></b>)
                </s:if>
              </td>
              <td class="td4"><s:property value="quantity"/></td>
              <td class="td5">
                <s:a action="cartAction_delete" namespace="/cart">
                  <s:param name="productId" value="product.productId"/>
                  Delete
                </s:a>
              </td>
            </tr>
            </s:iterator>
          </table>
          <div class="total-price">
            TotalPrice:<b><s:property value="#totalPrice"/></b>
          </div>
          <div class="operation">
            <div class="clear">
              <s:a action="cartAction_clear" namespace="/cart">Clear</s:a>
            </div>
            <div class="continue">
              <s:a action="index" namespace="/">Continue</s:a>
            </div>
            <div class="add">
              <s:a action="orderAction_add" namespace="/order">Settle</s:a>
            </div>
          </div>
        </div>
      </div>
      <div class="foot">
        <s:include value="/WEB-INF/JSP/foot.jsp"/>
      </div>
    </div>
    <script type="text/javascript" src="<s:url value='/JS/jquery-1.7.2.min.js'/>"></script>
    <script type="text/javascript" src="<s:url value='/JS/common.js'/>"></script>
  </body>
</html>